package utils

import (
	"encoding/json"
	"net/http"

	"filehive-backend/models"
)

// RespondJSON 响应 JSON
func RespondJSON(w http.ResponseWriter, statusCode int, data interface{}) {
	w.Header().Set("Content-Type", "application/json; charset=utf-8")
	w.WriteHeader(statusCode)
	json.NewEncoder(w).Encode(data)
}

// RespondError 错误响应
func RespondError(w http.ResponseWriter, statusCode int, message string) {
	RespondJSON(w, statusCode, models.APIResponse{
		Success: false,
		Message: message,
	})
}

// RespondSuccess 成功响应
func RespondSuccess(w http.ResponseWriter, message string, data interface{}) {
	RespondJSON(w, http.StatusOK, models.APIResponse{
		Success: true,
		Message: message,
		Data:    data,
	})
} 